<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>date() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>date()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>date()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/get-set/date/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/02-get-set/05-date.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().date(Number);
moment().date(); // &#x6570;&#x5B57;
moment().dates(Number);
moment().dates(); // &#x6570;&#x5B57;
</code></pre>

							</div>
<p>&#x83B7;&#x53D6;&#x6216;&#x8BBE;&#x7F6E;&#x6708;&#x4EFD;&#x7684;&#x65E5;&#x671F;&#x3002;</p>
<p>&#x63A5;&#x53D7; 1 &#x5230; 31 &#x4E4B;&#x95F4;&#x7684;&#x6570;&#x5B57;&#x3002;
&#x5982;&#x679C;&#x8D85;&#x51FA;&#x8303;&#x56F4;&#xFF0C;&#x5219;&#x5B83;&#x5C06;&#x4F1A;&#x5192;&#x6CE1;&#x8FBE;&#x5230;&#x6708;&#x4EFD;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;<code>Moment#date</code> &#x662F;&#x6708;&#x4EFD;&#x7684;&#x65E5;&#x671F;&#xFF0C;&#x800C; <code>Moment#day</code> &#x662F;&#x661F;&#x671F;&#x51E0;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5982;&#x679C;&#x94FE;&#x63A5;&#x591A;&#x4E2A;&#x64CD;&#x4F5C;&#x4EE5;&#x6784;&#x9020;&#x4E00;&#x4E2A;&#x65E5;&#x671F;&#xFF0C;&#x5219;&#x5E94;&#x4ECE;&#x5E74;&#x4EFD;&#x3001;&#x6708;&#x4EFD;&#x3001;&#x65E5;&#x671F;&#x7B49;&#x4F9D;&#x6B21;&#x5F00;&#x59CB;&#x3002;
&#x5426;&#x5219;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x5F97;&#x5230;&#x610F;&#x5916;&#x7684;&#x7ED3;&#x679C;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x5F53; <code>day=31</code> &#x5E76;&#x4E14;&#x5F53;&#x524D;&#x6708;&#x4EFD;&#x53EA;&#x6709; 30 &#x5929;&#x65F6;&#xFF08;&#x540C;&#x6837;&#x9002;&#x7528;&#x4E8E;&#x539F;&#x751F; JavaScript <code>Date</code> &#x7684;&#x64CD;&#x4F5C;&#xFF09;&#xFF0C;&#x8FD4;&#x56DE;&#x7684;&#x65E5;&#x671F;&#x5C06;&#x4F1A;&#x4E3A;&#x5F53;&#x524D;&#x6708;&#x4EFD;&#x7684; 30 &#x53F7;&#xFF08;&#x6709;&#x5173;&#x8BE6;&#x60C5;&#xFF0C;&#x53C2;&#x9605;<a href="javascript:window.open('http://nodejs.cn/s/atzJWy');" target="_blank" rel="nofollow">&#x6708;&#x4EFD;</a>&#xFF09;&#x3002;</p>
<p>&#x9519;&#x8BEF;&#xFF1A;<code>moment().date(day).month(month).year(year)</code></p>
<p>&#x6B63;&#x786E;&#xFF1A;<code>moment().year(year).month(month).date(day)</code></p>
<p><strong>2.16.0</strong> &#x8D77;&#x5E9F;&#x5F03;&#x4F7F;&#x7528; <code>moment().dates()</code>&#x3002;
&#x6539;&#x7528; <code>moment().date()</code>&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().date(Number);
moment().date(); // Number
moment().dates(Number);
moment().dates(); // Number
</code></pre>

							</div>
<p>Gets or sets the day of the month.</p>
<p>Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the months.</p>
<p><strong>Note:</strong> <code>Moment#date</code> is for the date of the month, and <code>Moment#day</code> is for the day of the week.</p>
<p><strong>Note:</strong> if you chain multiple actions to construct a date, you should start from a year, then a month, then a day etc. Otherwise you may get unexpected results, like when <code>day=31</code> and current month has only 30 days (the same applies to native JavaScript <code>Date</code> manipulation), the returned date will be the 30th of the current month (see <a href="javascript:window.open('http://momentjs.com/docs/#/get-set/month/');" target="_blank" rel="nofollow">month</a> for more details).</p>
<p>Bad: <code>moment().date(day).month(month).year(year)</code></p>
<p>Good: <code>moment().year(year).month(month).date(day)</code></p>
<p><strong>2.16.0</strong> deprecated using <code>moment().dates()</code>. Use <code>moment().date()</code> instead.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>